<?php

//echo br(3); ###########################################################################################

	$TEMP->set_file(array('handle' => DIR_VIEW_STUDENTS . 'myGrades.html'));
	
	$SAID = (!empty($_GET['said'])) ? _GET('said') : $activeSemester['sem_linker_idFK'];

	$semSubjList = $STUD->getStudentSubjectTakenListSeperateBySem($logUserID, $strCourseID, $SAID);
	
	$semActiveValidate = $STUD->getStudSemValidation($logUserID, $strCourseID, $SAID, $activeYear);
	if ( $semActiveValidate > 0 ) {
		$fontStrikeGrade = 'font-grey';
	}

	if ( !empty($semSubjList) ) {
		$TEMP->set_block('handle',  'subjects', 'subjectsRow');
		foreach($semSubjList as $semSubjListField => $studentSubjectList) {
			$semDesc = $DSC->getSemesterDescViaLinker($semSubjListField);
			$subjListHTML = '<table width="0" border="0" cellspacing="0" cellpadding="0" class="table-list-semester-subject">
								<tr>
									<td width="650" height="25" colspan="4" class="subject-taken-value-line">&nbsp;&nbsp;<span class="font-red"><strong>' . $semDesc['sem_desc'] . ' (' . $semDesc['sem_code'] . ')</span></strong></td>
									<td class="subject-taken-value-line">&nbsp;<strong>Units</strong></td>
									<td class="subject-taken-value-line">&nbsp;<strong>Final Grades</strong></td>
								</tr>
								<tr>
									<td height="5" colspan="5"></td>
								</tr>';
			if (!empty($studentSubjectList)) {
				$count = 1;
				foreach($studentSubjectList as $studentSubjectListVal) {
					
					$studentSubjectGrades 		 = $STUD->getStudentSubjectGrades($logUserID, $studentSubjectListVal['subj_idPK'], $strCourseID, $SAID);
					$studentReqesutSubjectDelete = $STUD->getStudentReqesutSubjectDelete($logUserID, $studentSubjectListVal['stud_subj_linker_idPK']);
					
					if (!empty($studentSubjectListVal['grade'])) {
						if ($studentSubjectListVal['grade'] == 'INC' || $studentSubjectListVal['grade'] == 'DRP') {
							$percentSymbol = '';
							$gradeConvert = ($studentSubjectListVal['grade'] == 'INC') ? '<span class="font-red">INC</span>' : '<span class="font-red">DROP</span>';
						}
						else {
							$gradeIfPercent = $globalCon->getGradeIfPercent($studentSubjectListVal['grade']);
							if ( $gradeIfPercent === true ) {
								$percentSymbol = '';
								$gradeConvert = '';
							}
							else {
								$percentSymbol = '%';
								$gradeConvert = $studentSubjectGrades['equivalence'];
							}
							//$percentSymbol = ( $gradeIfPercent === true ) ? '' : '%';
							//$gradeConvert = $studentSubjectGrades['equivalence'];
						}
					}
					else {
						$percentSymbol = '';
						$gradeConvert = '';
					}
					
					if ( !empty($studentReqesutSubjectDelete) ) {
						if ( $studentReqesutSubjectDelete['is_accepted'] == 'Y' ) $studStrikeGrade = '<span class="font-green">[A]</span>';
						elseif ( $studentReqesutSubjectDelete['is_accepted'] == 'N' ) $studStrikeGrade = '<span class="font-red">[D]</span>';
						else $studStrikeGrade = '<span class="font-grey">[P]</span>';
						$deleteButSubj = '<img id="but_trans_subj_id' . $studentSubjectListVal['subj_idPK'] . '" src="' . DIR_IMAGES . 'icon/recyclebin_d.png" border="0" title="' . $studentSubjectListVal['subj_desc'] . '"/>';
					}
					else {
						$studStrikeGrade = '';
						if (empty($studentSubjectListVal['grade'])) {
							$deleteButSubj = '<img id="but_trans_subj_id' . $studentSubjectListVal['subj_idPK'] . '" src="' . DIR_IMAGES . 'icon/recyclebin.png" onclick="popupDelete(\'' . $studentSubjectListVal['subj_idPK'] . '\', \'190\')" class="cursor-pointer" border="0" title="' . $studentSubjectListVal['subj_desc'] . '"/>';
						}
						else {
							$deleteButSubj = '<img id="but_trans_subj_id' . $studentSubjectListVal['subj_idPK'] . '" src="' . DIR_IMAGES . 'icon/recyclebin_d.png" border="0" title="' . $studentSubjectListVal['subj_desc'] . '"/>';
						}
					}
					
					if ( $studentSubjectListVal['stud_sem_active'] == $_ACTIVESEM_) {
						$dropSubject = '<div class="icon-button">
											&nbsp;' . $deleteButSubj . '
											<div class="delete-button-near-img" id="delete_button_' . $studentSubjectListVal['subj_idPK'] . '">
												<div class="delete-label">Delete <strong>' . $studentSubjectListVal['subj_code'] . '</strong>?</div>
												<div class="cursor-pointer delete-yes-no" onclick="deleteSubject(\'' . $studentSubjectListVal['stud_subj_linker_idPK'] . '\');">Yes</div>
												<div class="cursor-pointer delete-yes-no" onclick="popupDeleteHide(\'' . $studentSubjectListVal['subj_idPK'] . '\');">No</div>
											</div>
										</div>';
					}
					else {
						$dropSubject = '';
					}
					
					$subjListHTML .= '<tr>
										  <td width="20" class="subject-taken-value">' . $dropSubject . '</td>
										  <td width="20" class="subject-taken-value ' . $fontStrikeGrade . '">&nbsp;<strong>' . $count . '.</strong></td>
										  <td width="405" class="subject-taken-value ' . $fontStrikeGrade . '">&nbsp;' . $studentSubjectListVal['subj_desc'] . ' ' . $studStrikeGrade . '</td>
										  <td width="50" class="subject-taken-value ' . $fontStrikeGrade . '">&nbsp;' . $studentSubjectListVal['subj_code'] . '</td>
										  <td width="50" class="subject-taken-value ' . $fontStrikeGrade . '" align="left">&nbsp;&nbsp;&nbsp;' . abs($studentSubjectListVal['total_units']) . '</td>
										  <td width="120" class="subject-taken-value ' . $fontStrikeGrade . '" align="center">
										  	<div class="subject-grades">
												<div class="subject-grades-value">
										  			&nbsp;' . $studentSubjectListVal['grade'] . $percentSymbol . '
												</div>
												<div class="subject-grades-convert">
													&nbsp;&nbsp;' . $gradeConvert . '
												</div>
											</div>
											</td>
									  </tr>';
					$count++;
				}
			}
			$subjListHTML .= '</table><div class="subj-list-spacer"></div>';
			
			$TEMP->set_var(array('subj_list' => $subjListHTML));
			$TEMP->parse('subjectsRow', 'subjects', true);
		}
		
	}
	else {
		$TEMP->set_var(array('subj_list' => ''));
	}
	
	$TEMP->set_var(array('stud_sub_menu'	=> $studentDesignName,
						 'stud_active_sem'	=> $studActiveSemester,
						));
?>